/*
*编写一个函数，交换两个int型指针所指向的值，调用并检验该函数，输出交换后的值
*/
#include<iostream>
using namespace std;

void exchange(int *,int *);
int main()
{
	int iVal1 =10,iVal2=20;
	int *ip1 = &iVal1;
	int *ip2 = &iVal2;

	cout << "Before：iVal1 = " << iVal1 << ", iVal2 = " << iVal2 << endl;
	exchange(ip1,ip2);
	cout << "After：iVal1 = " << iVal1 << ", iVal2 = " << iVal2 << endl;

	system("pause");
	return 0;
}

void exchange(int *ip1,int *ip2)
{
	int tempVal;
	tempVal = *ip1;
	*ip1 = *ip2;
	*ip2 = tempVal;
}